<?php
    session_start();
    include('inc/db.php');
?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Edit-写意天空</title>
    <link rel="stylesheet" type="text/css" href="./static/css/editstyle.css" />
</head>
<body>
<div id="header">
    <p class="de">想了解未来，就关注现在</p>
    <div id="logo">
        <a href="index.php">写意天空</a>
    </div>
</div>
<?php echo $_SESSION['sess_var']?>
<div id="contact">
    <div id="up">
     <div id="left">
      <li><a href="./upload.html">Add Picture</a></li>
      <li><a href="./post.php">Add New</a></li>
     </div>
     <div id="center">
        <?php
        if(ctype_digit($_GET['id'])) {
            $result = mysql_query("SELECT * FROM post WHERE id=".$_GET['id']." limit 1");
            $post = mysql_fetch_assoc($result);
            }
        ?>

        <form method="post" action="post.php">
        <input type="hidden" name="post_id" value="<?=$_GET['id']?>" />
        <table border="0">
            <tr><td>标题</td></tr>
            <tr><td align="left"><input type="text"name="title"size="42" value="<?=$post['title']?>" maxlength="300"></td></tr>
            <tr><td>内容</td></tr>
            <tr><td><textarea name="content" rows="4" cols="34"><?=$post['content']?></textarea></td></tr>
            <tr><td>分类</td></tr>
            <tr><td align="left"><input type="text"name="categories"size="42" maxlength="300"></td></tr>
            <tr><td colspan="2" align="left"><span class="submit"><input type="submit" value="提交"/></span></td></tr>
        </table>
        </form>
     </div>
     <div id="right">
        <?php
        $ltp = mysql_query("SELECT * FROM post");
        $lists_total = mysql_num_rows($ltp);
        $ltc = mysql_query("SELECT *FROM comment");
        $comm_total = mysql_num_rows($ltc);
        ?>
      <li><?php echo $lists_total;?><a href="list.php"> Post </a></li>
      <li><?php echo $comm_total;?><a href="./post.php"> Comment</a></li>
     </div>
    </div>
    <div id="down">
    <h3>文章标题</h3>
        <?php
         $result = mysql_query("SELECT * FROM post order by id desc limit 1,20");
         while($row = mysql_fetch_array($result)){
         $id=$row['id'];
         echo '<div calss="post">';
         echo '<h4><a href="edit.php?id='.$id.'">'.$row['title'].'</a>'.'</h4>';
         echo '<a href="delete.php?id='.$id.'">'.删除.'</a>';
         echo '</div>';
         }
         $num=count($result);
       ?>
    </div>
</div>
</body>

</html>